Skip to content

使用RSA公钥验证签名 - VerifySignWithRsa

函数简介

使用RSA公钥验证数据的签名。

接口名称

VerifySignWithRsa

DLL调用

c
int VerifySignWithRsa(long instance, string message, string signature, int shaType, int paddingType, string publicCer);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
message字符串要验证的明文。
signature字符串签名数据。
shaType整数型哈希类型:0-MD5;1-SHA1;2-SHA256;3-SHA384;4-SHA512;5-SHA3-256;6-SHA3-384;7-SHA3-512。
paddingType整数型填充类型:0-Pkcs1;1-Pss。
publicCer字符串RSA公钥。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
std::string signature = ola.SignWithRsa("hello ola", privateKey, 2, 0);
int ok = ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
string signature = ola.SignWithRsa("hello ola", privateKey, 2, 0);
int ok = ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
signature = ola.SignWithRsa("hello ola", private_key, 2, 0)
ok = ola.VerifySignWithRsa("hello ola", signature, 2, 0, public_key)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);
cpp
var ola = com("OlaPlug.OlaSoft")
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);
text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
ola.VerifySignWithRsa("hello ola", signature, 2, 0, publicKey);

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
VerifySignWithRsa(instance, "hello ola", signature, 2, 0, publicKey);
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int VerifySignWithRsa(long ola, string message, string signature, int shaType, int paddingType, string publicCer);

long instance = CreateCOLAPlugInterFace();
int ok = VerifySignWithRsa(instance, "hello ola", signature, 2, 0, publicKey);
python
long instance = CreateCOLAPlugInterFace();
VerifySignWithRsa(instance, "hello ola", signature, 2, 0, publicKey);

返回值

返回值说明
1成功。
0失败。

注意事项

项目说明
验证时使用的哈希类型和填充类型必须与签名时一致验证时使用的哈希类型和填充类型必须与签名时一致。